package it.xiuxian.lib.utils

import java.lang.Exception

/**
 * @author zhouhaoyang
 * @since 6/21/21
 */
enum class Status {
    UNKNOWN,
    CONTAINS,
    NOT_CONTAINS
}
object RuntimeUtils {
    private var liveStatus: Status = Status.UNKNOWN
    private var luckycatStatus: Status = Status.UNKNOWN
    private var containsDP: Status = Status.UNKNOWN
    private var containsGame: Status = Status.UNKNOWN
    fun containsLiveSdk(): Boolean {
        if (liveStatus == Status.UNKNOWN) {
            try {
                Class.forName("com.bytedance.android.livesdkapi.TTLiveService")
                liveStatus = Status.CONTAINS
            } catch (e: Exception) {
                liveStatus = Status.NOT_CONTAINS
            }
        }
        return liveStatus == Status.CONTAINS
    }

    fun containsLuckyCat(): Boolean {
        if (luckycatStatus == Status.UNKNOWN) {
            try {
                Class.forName("com.pangrowth.business.luckycat.LuckyCatServiceImpl")
                luckycatStatus = Status.CONTAINS
            } catch (e: Exception) {
                luckycatStatus = Status.NOT_CONTAINS
            }
        }
        return luckycatStatus == Status.CONTAINS
    }

    fun containsDP(): Boolean {
        if (containsDP == Status.UNKNOWN) {
            try {
                Class.forName("com.bytedance.sdk.dp.DPSdk")
                containsDP = Status.CONTAINS
            } catch (e: Exception) {
                containsDP = Status.NOT_CONTAINS
            }
        }
        return containsDP == Status.CONTAINS
    }
    fun containsGame(): Boolean {
        if (containsGame == Status.UNKNOWN) {
            try {
                Class.forName("com.bytedance.pangolin.game.PangrowthGameSDK")
                containsGame = Status.CONTAINS
            } catch (e: Exception) {
                containsGame = Status.NOT_CONTAINS
            }
        }
        return containsGame == Status.CONTAINS
    }
}